<?php

namespace app\admin\dao;

use app\common\model\PromotionGroup;
use ShidianUtil\Thinkphp\Dao\DaoTrait;

/**
 * PromotionGroupDao 数据访问对象
 * Class PromotionGroupDao
 * @package app\admin\dao
 * @method PromotionGroup findByPK(?int $id, $field = true)
 * @method \think\Collection selectAll(?int $page, ?int $page_size, $field = true)
 * @method PromotionGroup insertActive(array $params, array $allow_field = [])
 * @method PromotionGroup updateActive(PromotionGroup $model, array $params, array $allow_field = [])
 * @method PromotionGroup findAndUpdateActive(int $id, array $params, array $allow_field = [])
 * @method PromotionGroup updateActiveByClosure(\Closure $closure, array $params, array $allow_field = [])
 * @method void deleteModel(PromotionGroup $model)
 * @method void deleteById(int|array|\Closure $id, bool $force = false)
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class PromotionGroupDao
{
    use DaoTrait;

    /**
     * @var PromotionGroup
     */
    private $baseModel;

    /**
     * PromotionGroupDao constructor.
     */
    public function __construct()
    {
        $this->baseModel = PromotionGroup::class;
    }

    public function select($page, $page_size)
    {
        $query = PromotionGroup::where('isDel', '0')
            ->order('id', 'ASC')
            ->paging($page, $page_size);

        return listOutput($query, $page_size);
    }

    public function find($id): ?PromotionGroup
    {
        return PromotionGroup::where('id', $id)
            ->find();
    }
}
